<!DOCTYPE html>
<html lang="zh-Hant">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}管理後台 - 日創科技{% endblock %}</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
    <style>
        .admin-sidebar {
            min-height: 100vh;
            background: #343a40;
            color: white;
            padding-top: 20px;
        }
        
        .admin-sidebar .nav-link {
            color: rgba(255,255,255,.8);
            padding: 10px 20px;
            margin: 5px 0;
            border-radius: 5px;
        }
        
        .admin-sidebar .nav-link:hover,
        .admin-sidebar .nav-link.active {
            color: white;
            background: rgba(255,255,255,.1);
        }
        
        .admin-sidebar .nav-link i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
        }
        
        .admin-content {
            padding: 20px;
        }
        
        .admin-header {
            background: white;
            padding: 15px 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,.1);
            margin-bottom: 20px;
        }
        
        .stat-card {
            background: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,.1);
            transition: transform 0.3s ease;
        }
        
        .stat-card:hover {
            transform: translateY(-5px);
        }
        
        .stat-icon {
            font-size: 2rem;
            margin-bottom: 15px;
            color: #007bff;
        }
    </style>
    {% block extra_css %}{% endblock %}
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <!-- 侧边栏 -->
            <div class="col-md-3 col-lg-2 admin-sidebar">
                <div class="text-center mb-4">
                    <img src="{{ url_for('static', filename='images/logo.png') }}" alt="Logo" width="50">
                    <h5 class="mt-2">日創科技</h5>
                </div>
                <nav class="nav flex-column">
                    <a class="nav-link {% if request.endpoint == 'admin.dashboard' %}active{% endif %}" 
                       href="{{ url_for('admin.dashboard') }}">
                        <i class="fas fa-tachometer-alt"></i> 儀表板
                    </a>
                    <a class="nav-link {% if request.endpoint == 'admin.news' %}active{% endif %}" 
                       href="{{ url_for('admin.news') }}">
                        <i class="fas fa-newspaper"></i> 資訊管理
                    </a>
                    <a class="nav-link {% if request.endpoint == 'admin.services' %}active{% endif %}" 
                       href="{{ url_for('admin.services') }}">
                        <i class="fas fa-cogs"></i> 業務範圍
                    </a>
                    <a class="nav-link {% if request.endpoint == 'admin.cases' %}active{% endif %}" 
                       href="{{ url_for('admin.cases') }}">
                        <i class="fas fa-briefcase"></i> 成功案例
                    </a>
                    <a class="nav-link {% if request.endpoint == 'admin.contacts' %}active{% endif %}" 
                       href="{{ url_for('admin.contacts') }}">
                        <i class="fas fa-envelope"></i> 諮詢管理
                    </a>
                    <a class="nav-link {% if request.endpoint == 'admin.settings' %}active{% endif %}" 
                       href="{{ url_for('admin.settings') }}">
                        <i class="fas fa-cog"></i> 系統設置
                    </a>
                    <a class="nav-link" href="{{ url_for('admin.logout') }}">
                        <i class="fas fa-sign-out-alt"></i> 登出
                    </a>
                </nav>
            </div>

            <!-- 主要内容区 -->
            <main class="col-md-9 col-lg-10 ms-sm-auto px-md-4">
                <!-- 顶部栏 -->
                <div class="admin-header d-flex justify-content-between align-items-center">
                    <h4 class="mb-0">{% block page_title %}{% endblock %}</h4>
                    <div class="user-info">
                        <span class="me-3">{{ current_user.username }}</span>
                        <a href="{{ url_for('admin.logout') }}" class="btn btn-outline-danger btn-sm">
                            <i class="fas fa-sign-out-alt"></i> 登出
                        </a>
                    </div>
                </div>

                <!-- 闪现消息 -->
                {% with messages = get_flashed_messages(with_categories=true) %}
                    {% if messages %}
                        {% for category, message in messages %}
                            <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                                {{ message }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                            </div>
                        {% endfor %}
                    {% endif %}
                {% endwith %}

                <!-- 页面主要内容 -->
                <div class="admin-content">
                    {% block content %}{% endblock %}
                </div>
            </main>
        </div>
    </div>

    <!-- Bootstrap Bundle JS -->
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
    {% block extra_js %}{% endblock %}
</body>
</html> 